package com.yqy.spring.bank.service.impl;

import com.yqy.spring.bank.dao.AccountDao;
import com.yqy.spring.bank.pojo.Account;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

@Service("isolation1")
public class IsolationService1{
    @Resource(name="accountDao")
    private AccountDao accountDao;
    /**
     * 测试事务的隔离性
     * 负责查询
     */
    @Transactional(isolation = Isolation.READ_COMMITTED,readOnly = true)
    public void getByAccountId(String accountId){
        Account account = accountDao.selectById(accountId);
        System.out.println("查询到的账户余额为："+account.getBalance());
    }
}
